package com.qf.controller;

import com.qf.pojo.response.BaseResponse;
import com.qf.utils.UploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/base")
public class BaseController {
    @Autowired
    UploadUtils uploadUtils;
    @RequestMapping("/upload")
    public BaseResponse upLoad(@RequestParam("file")MultipartFile multipartFile){
        String upload = uploadUtils.upload(multipartFile);
        if (StringUtils.isEmpty(upload)){
            return new BaseResponse().FAILED();
        }
        return new BaseResponse(1,"success",upload,null);
    }
}
